<?php
/*
$emails[] = 'HYPERLINK "mailto:anneso.richard@gmail.com"anneso.richard@gmail.com';
$emails[] = 'anit HYPERLINK mailto:sohier@gmail.com a.sohier@gmail.com';
$emails[] = 'HYPERLINK mailto:sophie.mertz@orange.fr sophie.mertz@orange.fr';
$emails[] = 'guillaume HYPERLINK mailto:chevalier01@gmail.com .chevalier01@gmail.com 	Option Finance, Promotion 98';
$emails[] = 'guillaume HYPERLINK mailto:chevalier_01@gmail.com .cheva_lier01@gmail.com 	Option Finance, Promotion 98';

foreach($emails as $email) {
	if(preg_match_all("/(HYPERLINK )/",$email)) {
		// Replace Quote and non caracter char ny nothing
		$email = str_replace('"',' ',$email);
		$email = preg_replace("/[^a-zA-Z0-9:@_. -]/",'', $email);
		$parts = explode(' ',$email);
		$visibleEmail = null;
		$foundHyperLink = 0;
		foreach($parts as $key => $part) {
			if(empty($part)) {
				continue;
			}
			
			if($part == 'HYPERLINK') {
				$foundHyperLink = 1;
				
			} elseif($foundHyperLink == 0) {
				$visibleEmail .= $part;
			} else {
			
				if($foundHyperLink == 1) {
					
				} elseif($foundHyperLink == 2) {
					$visibleEmail .= $part;
					break;
				}
				$foundHyperLink++;
			}
		}
		var_dump($visibleEmail);
	}
}
*/
use Hive\Ressource\Source\Parser\Viadeo;
use Hive\Ressource\Source;
$sources = Fox\Dao::finder(Source::className())
	->where('reference IS NOT NULL')
	->find();
foreach($sources as $source) {
	$reference = Viadeo::parse($source->reference);
	var_dump($reference);
}